<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>我的草稿</title>
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../CSS/media.css">
    <style>
        .layui-card-header {
            font-size: 18px;
        }

        .layui-col-md3 .layui-panel {
            height: 240px;
            box-shadow: 0px 0px 10px 5px #aaa;
            padding: 0px;
            border-radius: 5px;
            background-color: #00F7DE;
        }

        .layui-panel .layui-sys-title {
            height: 40px;
            /*vertical-align:middle;*/
            line-height: 40px;
            width: 100%;
            background-color: #ffffff;
            font-size: 18px;
        }

        .layui-sys-title img {
            /*line-height: 40px;*/
            vertical-align: middle;
            /*float: right;*/
        }
        .draft .layui-tab-title {
            border-bottom-style: none;
            height: 70px;
            line-height: 70px;
            width: 50%;
            display: inline-block;
        }
        .draft .layui-tab-title li {
            font-size: 18px;
            font-weight: bold;
            color: #868686;
            border-right: 2px #9c9c9c solid;
            line-height: 30px!important;
        }
        .draft .layui-tab-title li:last-child{
            border-right: none!important;
        }
        .draft .layui-this {
            color: #1E9FFF!important;
        }
        .draft .layui-this:after{
            border-bottom: 0px!important;
        }
        .s_btn{
            width: 40%;
            float: right;
            position: relative;
            margin-top: 15px;
        }
        .s_btn i{
            font-size: 28px;
            color: #fff;
            position: absolute;
            cursor: pointer;
            background: #1E9FFF;
            text-align: center;
            border-top-right-radius: 5px;
            border-bottom-right-radius: 5px;
            padding: 4px;
        }
        .s_btn input{
            height: 40px;
            background: #f1f1f1;
            border: none;
            font-size: 16px;
            width: 80%;
            display: inline-block;
        }
        .layui-elem-quote{
            background: unset!important;
            font-size: 16px;
            font-weight: bold;
            color: #868686;
            border-left: 5px solid #1E9FFF;
            line-height: 0px;
            margin-left: 10px;
        }
        .layui-col2{
            height: 260px;
            flex: 0 0 30%;
            padding-right: 10px;
            padding-left: 10px;
            cursor: pointer;
            box-sizing: border-box;
        }
        .layui-col img, .layui-col2 img {
            width: 100%;
        }
        .draft{
            width: 100%;
        }
        .draft_list{
            display: flex;
            width: 100%;
            flex-wrap: wrap;
            margin-top: 30px;
        }
        .layui-col2-card{
            box-shadow: 0 4px 11px 0px #bbbbbb;
        }
        .add {
            background-image: url(../../static/IMG/Personal/add.png);
            background-repeat: no-repeat;
            background-size: 30%;
            background-position: center;
            height: 220px;
        }
        .app_list_imfor_name {
            display: inline-block;
            width: 55%;
            max-width: 190px;
            height: 40px;
            float: left;
            line-height: 40px;
            text-indent: 10px;
            font-weight: bold;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .app_list_imfor_data {
            display: inline-block;
            width: 45%;
            height: 40px;
            line-height: 40px;
        }
        .app_list_imfor_data > div {
            float: right;
            margin-right: 10px;
        }
        .nav{
            display: none;
            width: 80px;
            height: 70px;
            background: #1E9FFF;
            position: absolute;
            color: #fff;
            text-align: center;
            padding: 8px 0px;
            box-sizing: border-box;
            border-radius: 4px;
        }
        .nav li{
            height: 27px;
            line-height: 27px;
            cursor: pointer;
        }
        .nav li:hover{
            text-decoration: underline;
        }
        .navHandel{
            height: 30px !important;
            width:30px!important;
            position: absolute;
            right:0px;
            bottom: 50px;
        }
    </style>
</head>
<body>
<div class="layui-tab layui-tab-brief draft" lay-filter="draft">
    <ul class="layui-tab-title">
        <li>待审核</li>
        <li>已通过</li>
        <li>未通过</li>
    </ul>
    <div class="s_btn">
        <input type="text" name="title"  placeholder="请输入" autocomplete="off" class="layui-input search">
        <i class="layui-icon ">&#xe615;</i>
    </div>
    <div class="layui-tab-content" style="background-color: #ffffff;">
        <div class="layui-tab-item layui-show inAudit">
            <div class="draft_list">
            </div>
        </div>
        <div class="layui-tab-item adopt">
            <div class="draft_list">
            </div>
        </div>
        <div class="layui-tab-item notPass">
            <div class="draft_list">
            </div>
        </div>
    </div>
</div>
<!--菜单-->
<ul class="nav">
    <li onclick="edit(this)">编辑</li>
    <li onclick="r_Cancel(this)">取消发布</li>
</ul>
<script src="../../JS/jquery-2.0.3.js"></script>
<script src="../../node_modules/iframeResizer.contentWindow.js"></script>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script>
    $(function () {

        //点击其他地方菜单栏隐藏
        $(document).click(function (e) {
            if ($('.nav').css('display') !== 'none') {
                e = e || window.event;
                if (e.target.className !== 'navHandel'){
                    $('.nav').hide();
                }
            }
        })
        //点击列表跳转详情页
        $('.draft_list').on('click','.layui-col2-card',function (e) {
            e = e || window.event;
            if (e.target.className === 'navHandel') return;
            //获取当前样式的id
            var id = $(this).attr('cId');
            parent.parent.document.getElementById('view').src = "HTML/comment.html?id="+id+'&type=0';
        })
    })
    var tabHandleArr = [0];
    var tabHandle = 0;//当前点击的tab下标
    var type = ['inAudit','adopt','notPass'];
    var statusArr = [0,1,3];
    var flow = null;
    layui.use(['element','flow'], function () {
        var element = layui.element;
            flow = layui.flow;
        element.on('tab(draft)', function(data){
            tabHandle = data.index;
            if (tabHandleArr.indexOf(data.index) === -1) {
                var param = {
                    'condition': {
                        'status': parseInt(statusArr[data.index]),
                        'userid': parent.parent.getLocalStorage('JSXM').id,
                        'creator': parent.parent.getLocalStorage('JSXM').id
                    },
                };
                parent.parent.getFlowDataByPost(parent.parent.defaultUrl+'/app/selAppByPage',param,1,flow,getList,type[data.index],0);
                tabHandleArr.push(data.index);
            }
        });

        //调用获取数据接口
        var param = {
            'condition': {
                'status': 0,
                'userid': parent.parent.getLocalStorage('JSXM').id,
                'creator': parent.parent.getLocalStorage('JSXM').id
            },
        };
        parent.parent.getFlowDataByPost(parent.parent.defaultUrl+'/app/selAppByPage',param,1,flow,getList,'inAudit',0);
    });

    function getList(data,type,type2) {
        if (type2) {
            $('.'+type).find('.draft_list').html('');
        }
        var html = ''
        for (var i = 0,l = data.length;i<l;i++) {
            var img = data[i].img || (data[i].content && JSON.parse(data[i].content).img) ;
            html += '            <div class="layui-col2">\n' +
                '                <div cId="'+data[i].id+'" class="layui-col2-card" style="position: relative;">\n' +
                '                    <img class="AppImg" src="'+img+'">\n' +
                '                    <img class="navHandel" src="../../static/IMG/Common/editor.png" onclick="showNav(this,\''+data[i].id+'\',\''+type+'\');" />\n' +
                '                    <div class="app_list_imfor">\n' +
                '                        <div class="app_list_imfor_name">'+data[i].name+'</div>\n' +
                '                        <div class="app_list_imfor_data">\n' +
                '                            <div class="comments">\n' +
                '                                <i class="layui-icon">&#xe63a;</i><!--评论-->\n' +
                '                                <span>'+data[i].commentnum+'</span>\n' +
                '                            </div>\n' +
                '                            <div class="icon-socre">\n' +
                '                                <i class="layui-icon">&#xe67b;</i><!--评分-->\n' +
                '                                <span>'+data[i].score+'</span>\n' +
                '                            </div>\n' +
                '                            <div class="collect">\n' +
                '                            </div>\n' +
                '                        </div>\n' +
                '                    </div>\n' +
                '                </div>\n' +
                '            </div>'
        }
        html +=   '</div>'
        $('.'+type).find('.draft_list').append(html);
    }


    //编辑
    function edit(obj) {
        var id = parseInt($(obj).parent().attr('key'));
        var $view = parent.parent.document.getElementById("view");
        $view.style.marginTop = '0px';
        $view.src = "HTML/Application/appEdit.html?id="+id;
    }

    //取消发布
    function r_Cancel(obj) {
        var id = parseInt($(obj).parent().attr('key'));
        parent.parent.ajaxGet(parent.parent.defaultUrl+'/app/cancelPublish',{'id':id},function (data) {
            if (data.code === 200) {
                parent.layer.msg('操作成功');
                var param = {
                    'condition': {
                        'status': parseInt(statusArr[tabHandle]),
                        'userid': parent.parent.getLocalStorage('JSXM').id,
                        'creator': parent.parent.getLocalStorage('JSXM').id
                    },
                };
                parent.parent.getFlowDataByPost(parent.parent.defaultUrl+'/app/selAppByPage',param,1,flow,getList,type[tabHandle],1);
            }
        })
    }

    //编辑按钮
    function showNav(obj,id,type) {
        var left = $(obj).offset().left - 80;
        var top = $(obj).offset().top - 40;
        $('.nav').show().css({'left':left,'top':top}).attr({'key':id,'type':type});
    }
</script>
</body>
</html>